<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.7.1.min.js"></script>
</head>
<body>


<ul>
    <li>苹果</li>
    <li>香蕉</li>
    <li>橘子</li>
    <li>荔枝</li>
    <li>芭乐</li>
</ul>


<script>

    /*
        let $ul = $("ul li");
        $ul.each(function () {
        })
    */


    $('ul li').each(function (index, e) {
        // console.log(index + ":" + e);
        //回调函数中的每个元素都是dom元素
        $(e).prepend((index + 1) + '.');

        if (index % 2 == 0) {
            $(e).css('background', 'red');
        }
    })


</script>


</body>
</html>